//
//  SHomeViewController.m
//  PocketFM
//
//  Created by sun on 15/12/16.
//  Copyright © 2015年 Sun. All rights reserved.
//
#define HomeHead @"http://d.fm.ifeng.com/fm/read/fmd/ios/getCardById_611.html"
#define HomeBody @"appid=TRWLY&cid=[{id%3A64}%2C{id%3A72}%2C{id%3A81}%2C{id%3A69}%2C{id%3A93}%2C{id%3A105}%2C{id%3A60}%2C{id%3A88}%2C{id%3A38}%2C{id%3A58}%2C{id%3A106}%2C{id%3A87}%2C{id%3A86}%2C{id%3A109}%2C{id%3A83}%2C{id%3A59}%2C{id%3A57}%2C{id%3A70}%2C{id%3A98}%2C{id%3A101}%2C{id%3A102}%2C{id%3A108}%2C{id%3A62}%2C{id%3A65}%2C{id%3A107}%2C{id%3A37}%2C{id%3A100}%2C{id%3A84}%2C{id%3A103}]&sign=75F3DA93E0A5BD8A5CC8E6273DEED4F0&timestamp=1450163648"
#import "SHomeViewController.h"
#import "IconTableViewCell.h"
#import "SHotPlayerTableViewCell.h"
#import "STopTableViewCell.h"
#import "STwoTableViewCell.h"
#import "SManagerTableViewCell.h"
#import "SFiveTableViewCell.h"
#import "STextTableViewCell.h"
#import "STextTableViewCell2.h"
#import "ListCategoryModel.h"
#import "UrlHelper.h"
@interface SHomeViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) UrlHelper *helper;
@end

@implementation SHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = NO;
    
    self.helper = [UrlHelper shareHelper];
    [self.helper getDictionaryWithUrl:HomeHead urlBody:HomeBody success:^(ListCategoryModel *model) {
        [self.tableView reloadData];
    } fail:nil];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.section == 1){
        STopTableViewCell *cell = [STopTableViewCell cellWithTabelView:tableView];
        return cell;
    }else if(indexPath.section > 6 && indexPath.section < 30){
        STwoTableViewCell *cell = [STwoTableViewCell cellWithTabelView:tableView];
        return cell;
    }else if(indexPath.section == 30){
        SManagerTableViewCell *cell = [SManagerTableViewCell cellWithTabelView:tableView];
        return cell;
    }else if (indexPath.section == 5 && indexPath.row == 0){
        SFiveTableViewCell *cell = [SFiveTableViewCell cellWithTabelView:tableView];
        return cell;
    }else if(indexPath.section == 5 && indexPath.row == 1){
        STextTableViewCell *cell = [STextTableViewCell cellWithTabelView:tableView];
        return cell;
    }else if(indexPath.section == 5 && indexPath.row == 2){
        STextTableViewCell2 *cell = [STextTableViewCell2 cellWithTabelView:tableView];
        return cell;
    }else{
        SHotPlayerTableViewCell *cell = [SHotPlayerTableViewCell cellWithTabelView:tableView];
        return cell;
    }
    
    //return nil;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 31;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 5) {
        return 3;
    }
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 1) {
        return 55;
    }else if (indexPath.section > 6){
        return 138;
    }else if (indexPath.section == 30){
        return 42;
    }else if (indexPath.section == 5 && indexPath.row == 0){
        return 143;
    }else if (indexPath.section == 5 && (indexPath.row == 1 || indexPath.row == 2)){
        return 57;
    }
    return 160;
}
@end
